package com.news.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
@WebServlet("/a")
public class A extends HttpServlet {
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//一种保护，让其它服务器不能访问此应用
		response.setHeader("Access-Control-Allow-Origin", "*");
		System.out.println("来过");
		response.setContentType("text/json;charset=utf-8");
//		response.setContentType("text/plain;charset=utf-8");
		response.getWriter().append("{\"age\":123,\"name\":\"yang\"}");
	}

 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 doGet(request, response);
	}

}
